package com.example.boot2mybatis.pubsub;


import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;


@Order(1)
@Service
public class AccountService implements ApplicationListener<LoginSuccessEvent> {

    // 模拟积分功能
    public void addAccountScore(String uname) {
        System.out.println(uname + "加了1分");
    }

    @Override
    public void onApplicationEvent(LoginSuccessEvent event) {
        System.out.println("=====AccountService======收到事件=====");

        UserEntity source = (UserEntity) event.getSource();
        addAccountScore(source.getUname());
    }
}

